# -*- coding: utf-8 -*-

print('hello word !!! 闭包演示');


def lazy_sum(*args):
    def sum():
        ax = 0
        for n in args:
            ax += n
        return ax

    return sum


# a = lazy_sum(222)
# print(a())

def count():
    a = 0
    print("count 调用了%d次" % a)

    def work():
        a = a + 1

    return work


# a = count()
#
# # 调用一次内部函数
# a();


def outer():
    num = 10


def outer():
    num = 10


def inner():
    nonlocal num  # nonlocal关键字声明
    num = 100
    print(num)


inner()
print(num)
outer()
